var t = getApp();

Page({
    data: {
        Data: {},
        showAll: !1,
        time: "",
        Day: "",
        Hour: "",
        Min: "",
        Sec: "",
        stop: !1,
        songStop: !0,
        button: 0,
        button_name: "",
        goods_id: "",
        is_store: 0,
        wheels: [],
        start: "",
        end: "",
        commission_amount: [],
        timeShow: 0,
        stores: [],
        business: [],
        link: "",
        readyState: 0,
        clientWidths: "",
        member_count: "",
        shareInfo: {},
        isSetShare: 0
    },
    onLoad: function(t) {
        this.setData({
            id: t.id
        }), this.initData(), this.getData();
    },
    linkTo: function() {
        t._isTextEmpty(this.data.link1) && wx.navigateTo({
            url: "/packageA/member/storeApply/storeApply"
        });
    },
    initData: function() {
        this.setData({
            Data: {},
            showAll: !1,
            time: "",
            Day: "",
            Hour: "",
            Min: "",
            Sec: "",
            stop: !1,
            songStop: !0,
            button: 0,
            button_name: "",
            goods_id: "",
            is_store: 0,
            wheels: [],
            start: "",
            end: "",
            commission_amount: [],
            timeShow: 0,
            stores: [],
            business: [],
            link: "",
            readyState: 0,
            clientWidths: "",
            member_count: "",
            shareInfo: {},
            isSetShare: 0
        });
    },
    play: function(t) {
        "plays" == t.currentTarget.dataset.info ? (this.innerAudioContext.pause(), this.setData({
            songStop: !0
        })) : (this.innerAudioContext.play(), this.setData({
            songStop: !1
        }));
    },
    showAlltap: function(t) {
        this.setData({
            showAll: !this.data.showAll
        });
    },
    countdown: function() {
        var t = this, a = Date.parse(new Date()) / 1e3;
        if (this.data.end - a <= 0) this.stop = !0; else {
            var o = this.data.end - a, e = parseInt(o / 60 / 60 / 24), n = parseInt(o / 60 / 60 % 24), i = parseInt(o / 60 % 60), s = parseInt(o % 60);
            n = n > 9 ? n : "0" + n, i = i > 9 ? i : "0" + i, s = s > 9 ? s : "0" + s, this.setData({
                Day: e,
                Hour: n,
                Min: i,
                Sec: s
            }), setTimeout(function() {
                t.countdown();
            }, 1e3);
        }
    },
    toGoods: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a
        });
    },
    toPage: function(a) {
        var o = a.currentTarget.dataset.val;
        t._isTextEmpty(o.store_name) ? t._isTextEmpty(o.hotel_name) || wx.navigateTo({
            url: "/packageC/hotel/HotelHome/HotelHome?id=" + o.id
        }) : wx.navigateTo({
            url: "/packageC/o2o/o2oStore/o2oStore?store_id=" + o.id
        });
    },
    gobannerlink: function(t) {
        try {
            wx.navigateTo({
                url: this.data.link2
            });
        } catch (t) {
            console.log(t);
        }
    },
    gomiandan: function(a) {
        var o = a.currentTarget.dataset.info.link;
        if (!t._isTextEmpty(o)) try {
            wx.navigateTo({
                url: o
            });
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getData: function() {
        var a = t.getNetAddresss("plugin.business-activity.frontend.controllers.activity.getActivityById"), o = this;
        t._getNetWork({
            data: {
                activity_id: 2
            },
            url: a,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    console.log(e), e.data.activity.audio_link && (o.autoPlay(), o.innerAudioContext.src = e.data.activity.audio_link, 
                    o.innerAudioContext.play(), o.setData({
                        songStop: !1
                    }));
                    for (var n = 0; n < e.data.wheels.length; n++) t._isTextEmpty(e.data.wheels[n].has_one_store) ? e.data.wheels[n].showStore = !1 : e.data.wheels[n].showStore = !0;
                    o.setData({
                        Data: e.data.activity,
                        button: e.data.activity.button,
                        button_name: e.data.activity.button_name,
                        member_count: e.data.member_count,
                        goods_id: e.data.goods_id,
                        wheels: e.data.wheels,
                        is_store_button: e.data.is_store_button,
                        stores: e.data.stores.concat(e.data.hotels),
                        commission_amount: e.data.commission_amount,
                        start: e.data.activity.countdown_time[0],
                        end: e.data.activity.countdown_time[1],
                        timeShow: o.showTime() ? e.data.activity.countdown : 0,
                        isSetShare: e.data.share_status,
                        shareInfo: e.data.share_data,
                        link1: e.data.activity.miniLink1,
                        link2: e.data.activity.miniLink2,
                        miandanPto: !0
                    }), console.log(o.data.wheels), wx.setNavigationBarTitle({
                        title: e.data.activity.name
                    }), o.countdown(), o.StoreArr(), console.log(o.data.business);
                }
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    StoreArr: function() {
        for (var t = Math.ceil(this.data.stores.length / 10), a = [], o = 1; o <= t; o++) a.push(this.data.stores.slice(10 * (o - 1), 10 * o));
        this.setData({
            business: this.data.business.concat(a)
        }), console.log(this.data.business);
    },
    showTime: function() {
        var t = new Date().getTime() / 1e3, a = this.data.start;
        return console.log(t >= a), t >= a;
    },
    autoPlay: function() {
        var t = this;
        this.innerAudioContext = wx.createInnerAudioContext(), this.innerAudioContext.onCanplay(function() {}), 
        this.innerAudioContext.onPlay(function() {
            console.log("开始播放"), console.log(t.innerAudioContext.duration);
        });
    }
});